﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UploadSinglePhoto.ascx.cs" Inherits="Besture.UI.Control.UploadSinglePhoto" %>
<script language="javascript" type="text/javascript">
    /*上传图片*/
    $(document).ready(function () {
        /*模板图片控件*/
        $("#uploadify<%=PhotoDivID %>").uploadify({
            'swf': '/Admin/PlugIn/jquery.uploadify/uploadify.swf',
            'method': 'get',
            'uploader': '/Admin/Control/UploadPhoto.aspx',
            'formData': { 'FolderPath': '<%=FolderPath %>', 'NeedThumbnail': '<%=NeedThumbnail %>', 'ThumbnailFolderPath': '<%=ThumbnailFolderPath %>', 'ThumbnailWidth': '<%=ThumbnailWidth %>', 'ThumbnailHeight': '<%=ThumbnailHeight %>' },
            'fileObjName': "ProductPhotoFile",
            'folder': '/Upload/',
            'queueID': 'fileQueue<%=PhotoDivID %>',
            'auto': true,
            'multi': false,
            'fileTypeExts': "*.jpg;*.png;*.gif;",
            'fileTypeDesc': 'Web Image Files (.JPG, .GIF, .PNG)',
            'buttonImage': '/Admin/PlugIn/jquery.uploadify/browse-btn.png',
            'cancelImg': '/Admin/PlugIn/jquery.uploadify/uploadify-cancel.png',
            'width': 120,
            'height': 30,
            'wmode': 'transparent',
            'onUploadSuccess': function (file, data, response) {//上传完成时触发（每个文件触发一次）
                if (!response) {
                    alert("网络异常，上传失败！");
                } else {
                    if (data != "0") {
                        $("#<%=PhotoDivID %>_div").remove();
                        var serverDataArgs = data.split("|");
                        var imgUrl = serverDataArgs[0];
                        //添加图片地址同样赋值已存图片文本框，以便验证通过
                        $("#<%=txtImageUrl.ClientID %>").val("'<%=folderPathTemp %>" + imgUrl + "'");
                        //$("#<%=txtImageUrl.ClientID %>").val(imgUrl);
                        var strhtml = "";
                        strhtml = strhtml + ("<div class='element' id='<%=PhotoDivID %>_div'>");
                        strhtml = strhtml + ("    <div> <img style='width: 160px;  height: 160px;  border: 1px solid #f0f0f0;' src='<%=folderPathTemp %>" + imgUrl + "' alt='' />");
                        strhtml = strhtml + ("    </div>");
                        strhtml = strhtml + ("</div>");
                        $("#<%=PhotoDivID %>").html("");
                        $("#<%=PhotoDivID %>").append(strhtml);
                    }
                }
            }

        });
    });
</script>

<img src="<%=RequiredImageUrl %>" align="absMiddle" style="float: left; margin-top: 10px;" />
<div  style="float: left;width: 130px;">
    <div class="uploadSinglePhotoDiv" id="<%=PhotoDivID %>">
        <%=InitText %>
    </div>
    <!--上传模板图片控件-->
    <div  style="height: 35px; background-color: #FFFFFF; padding: 15px 5px 5px 5px;">
        <span style="font-size: 95%; display: none; color: #666666" id="tipsSpan">※<%=Tips%></span>
        <!--上传模板图片控件-->
        <input type="file" name="uploadify<%=PhotoDivID %>" id="uploadify<%=PhotoDivID %>" />&nbsp;
    </div> 
    <!--图片地址-->
    <asp:TextBox runat="server" ID="txtImageUrl" Style="display: none"></asp:TextBox>
</div>